package dev.ece.suit.hexmap;

import dev.ece.util.lib.Vector2f;
import dev.ece.util.lib.Vector3f;

public class MapCell {

	private int row;
	
	private int col;
	
	private Terrain terrain;
	
	private Vector3f center;
	
	private Vector3f centernormal;
	
	private Vector2f centeruv;
	
	private Vector3f[][] vertice;
	
	private Vector3f[][] normals;
	
	private Vector2f[][] uv;
	/**
	 * 0、左上，1、左，2、左下，3、右下，4、右，5右上
	 * 显示时取3、4、5
	 */
	private MapCrevice[] neighbors = new MapCrevice[6];
	
	/**
	 * 0、上，1、左上，2、左下，3、下、4、右下，5、右上
	 * 显示时取4、5
	 */
	private MapTriangle[] triangles = new MapTriangle[6];
	
	private int first;
	
	public MapCell(
			Terrain terrain, int row, int col, int first, 
			Vector3f center, Vector3f centernormal, Vector2f centeruv, 
			Vector3f[][] vertice, Vector3f[][] normals, Vector2f[][] uv) {
		this.terrain = terrain;
		this.row = row;
		this.col = col;
		this.first = first;
		this.center = center;
		this.centernormal = centernormal;
		this.centeruv = centeruv;
		this.vertice = vertice;
		this.normals = normals;
		this.uv = uv;
	}
	
	public void renderDepth(MapModel model) {
		model.getTerrainModelCreator().render(this);
	}
	
	protected void glShader(MapModel model, HexMapCellShader cellShader) {
		getTerrain().glCellShader(cellShader, model.getTerrainModelCreator());
	}

	public void render(MapModel model, HexMapCellShader cellShader) {
		glShader(model, cellShader);
		renderDepth(model);
	}

	public Terrain getTerrain() {
		return terrain;
	}

	public Vector3f getCenter() {
		return center;
	}

	public Vector3f[][] getVertice() {
		return vertice;
	}

	public int getFirst() {
		return first;
	}

	public int getRow() {
		return row;
	}

	public int getCol() {
		return col;
	}

	public Vector3f getCenternormal() {
		return centernormal;
	}

	public Vector2f getCenteruv() {
		return centeruv;
	}

	public Vector3f[][] getNormals() {
		return normals;
	}

	public MapCrevice[] getNeighbors() {
		return neighbors;
	}

	public MapTriangle[] getTriangles() {
		return triangles;
	}

	public Vector2f[][] getUv() {
		return uv;
	}
	
}
